package com.start.cloud.robotcore.properties;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by xxu on 2018/4/23.
 */
@Configuration
@EnableConfigurationProperties
public class RobotConfigBootstrapConfiguration {

    @Bean(name="ownConfig")
    public ConfigServicePropertySourceLocator configServicePropertySourceLocator() {
        return new ConfigServicePropertySourceLocator(null) {
            @Override
            public org.springframework.core.env.PropertySource<?> locate(org.springframework.core.env.Environment environment) {
                return RobotClientConfiguration.get().getCompositeProperty();
            }
        };
    }
}
